<!-- Ticket Edit Page -->
<div class="content" id="tickets_edit">
	<a href="#/tickets/list">Back</a>
	<div class="ticket">
		<h3 id="tickets_edit_name"></h3>
		<hr/>
		<table width="100%">
			<tbody>
				<tr>
					<th>Type:</th>
					<td id="tickets_edit_type"></td>
					<th>Submitted On:</th>
					<td id="tickets_edit_date"></td>
				</tr>
				<tr>
					<th>Project:</th>
					<td id="tickets_edit_project"></td>
					<th>Submitted By:</th>
					<td id="tickets_edit_submitted_by"></td>
				</tr>
				<tr>
					<th>Release:</th>
					<td id="tickets_edit_release"></td>
					<th>Owner:</th>
					<td id="tickets_edit_owner"></td>
				</tr>
				<tr>
					<th>Total Hours:</th>
					<td id="tickets_edit_hours"></td>
					<th>Estimated Hours:</th>
					<td id="tickets_edit_estimated_hours"></td>
				</tr>
			</tbody>
		</table>
		<hr/>
		<p id="tickets_edit_description"></p>
	</div>

	<h3>Change history</h3>
	<div id="tickets_edit_changelog" class="changelog"></div>

	<form>
	</form>
</div>
<script>
	$("div.content#tickets_edit").bind("load", 
		function(event, id){
			$("div#tickets_edit table tbody td").empty();
			$("div#tickets_edit p#tickets_edit_description").empty();
			$("div#tickets_edit h3#tickets_edit_name").empty();
			env.models.Ticket.get(id, function(ticket){
				var project = getProject(ticket.props.project.id);
				$("#tickets_edit_name").text(ticket.props.name);
				$("#tickets_edit_type").text(ticket.props.type);
				$("#tickets_edit_date").text(ticket.props.date);
				$("#tickets_edit_project").text(project.name);

				if(ticket.props.submitted_by && ticket.props.submitted_by.id){
					env.models.User.get(ticket.props.submitted_by.id, function(user){
						$("#tickets_edit_submitted_by").text(user.name);
					});
				}
				if(ticket.props.release && ticket.props.release.id){
					env.models.Release.get(ticket.props.release.id, function(r){
						$("#tickets_edit_release").text(r.props.name);
					});
				}

				if(ticket.props.owner && ticket.props.owner.id){
					env.models.User.get(ticket.props.owner.id, function(user){
						$("#tickets_edit_owner").text(user.name);
					});
				}

				$("#tickets_edit_hours").text(ticket.props.hours);
				$("#tickets_edit_estimated_hours").text(ticket.props.estimated_hours);
				$("#tickets_edit_description").text(ticket.props.description);

				$("#tickets_edit input[@name='name']").val(ticket.props.name);
				$("#tickets_edit input[@name='id']").val(ticket.props.id);
				$("#tickets_edit textarea[@name='description']").val(ticket.props.description);
			});
		}
	);
</script>
<!-- /Ticket Edit page -->
